package com.atguigu.springcloud.alibaba.controller;

import com.alibaba.nacos.api.config.annotation.NacosProperty;
import com.alibaba.nacos.api.config.annotation.NacosValue;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @auther zzyy
 * @create 2020-02-23 17:02
 */
@RestController
@RefreshScope //支持Nacos的动态刷新功能，这个是spring cloud的
public class ConfigClientController {
    @Value("${config.info}")
    private String configInfo;

    /**
     * TODO 没效果
     */
    @NacosValue(value = "${config.nacosValue}", autoRefreshed = true)
    private String nacosValue;

    /**
     * TODO 没效果
     */
    @NacosProperty("config.info")
    private String nacosProperty;

    @GetMapping("/config/info")
    public String getConfigInfo() {
        return configInfo + "----------" + nacosValue + "---------" + nacosProperty;
    }
}
